Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

296
Visualizações
Passing multiple "key-value" pairs as a parameter to a JS function

I have a date range picker, and I want to pass the two dates (startDate, endDate) to handleFilterChange, which builds an filter object to save in session storage. Currently I try to call the function, giving parameters as two arrays, which obviously doesn't work. Calling the function twice also didn't work.

Is this thing even possible and if, then what would be a correct way to pass these two dates to this function?

handleFilterChange

const handleFilterChange = (value, title) => {
    clearPreviousResults();
    const newFilters = {
        ...filters,
        [title]: value,
    };

    saveFilterValue(newFilters, FILTERS_STORAGE_KEY);
    setFilters(newFilters)

date picker

const handleDateRangeChange = dates => {
    if (!dates || dates.length <= 1) {
        return;
    }
    handleFilterChange( ["startDate", "endDate"], [dates[0], dates[1]] );
    };
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I am assuming you are trying to save an object in the LocalStorage or session. I would rather send the whole dates array to handleFilterChange function.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda